package com.fancy.user.config;

import com.fancy.user.interceptor.JwtAuthInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置类
 */
@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {

    private final JwtAuthInterceptor jwtAuthInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtAuthInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(
                    "/users/register",
                    "/users/login",
                    "/users/logout",
                    "/doc.html#/**",
                    "/doc.html/**",
                    "/swagger-ui/**",
                    "/v2/api-docs",
                    "/swagger-resources/**",
                    "/webjars/**",
                    "/favicon.ico",
                    "/error"
                );
    }
}
